<?php
class Producto_ajeno_model extends Model
{
    function guardar()
    {

        $new_member_insert_data = array(
           'marca' => $this->input->post('marca'),
            'modelo' => $this->input->post('modelo'),
            'nombre' => $this->input->post('nombre'),
            'tamano' => $this->input->post('tamano'),
            'nacionalidad'=> $this->input->post('nacionalidad'),

        );
        //   log_message('INFO',"*************".print_r($new_member_insert_data,true));
        $insert = $this->db->insert('producto_ajeno', $new_member_insert_data);
        return $insert;
    }


    function modificar()
    {
        $new_member_update_data = array(
            'marca' => $this->input->post('marca'),
            'modelo' => $this->input->post('modelo'),
            'nombre' => $this->input->post('nombre'),
            'tamano' => $this->input->post('tamano'),
            'nacionalidad'=> $this->input->post('nacionalidad'),
            //'password' => md5($this->input->post('password'))
        );
        //   log_message('INFO',"*************".print_r($new_member_insert_data,true));
        $this->db->where('modelo', $new_member_update_data['modelo']);
       // echo($new_member_update_data['modelo']);
        return $this->db->update('producto_ajeno', $new_member_update_data);


    }

    function eliminar()
    {
        $carnet = $this->input->post('modelo');
        $this->db->where('modelo', $carnet);
        return $this->db->delete('producto_ajeno');
    }

//busqueda
    function obtener($id)
    {
       $producto_ajeno = array();

        $query = $this->db->get_where('producto_ajeno', array('modelo' => $id));
        $producto_ajeno = $query->result();
        return $producto_ajeno;
    }
 //selecciona el codigo
    function obtenerListaModelos()
    {
        $query = $this->db->query("SELECT modelo FROM producto_ajeno;");
        return $query->result_array();
    }

}
//$empleado = array();

//$query = $this->db->get_where('empleado',array('carnet' => $id));
//$empleado = $query->result();
//return $empleado;